/**
 * Created by thinkl on 2017/7/19.
 */
$(function () {
    var app_data = {
        order_detail: {},
        order_id: getQueryString('order_id'),
        order_address_default: {},
        order_address: {},
    };
    var app = new Vue({
        el: '#order_detail',
        data: app_data,
        methods: {
            chose_address: function (order_id) {
                location.href = '/static/address_list/address_list.html?order_id=' + order_id
            },
            order_pay: function (order_id) {
                $.post('/order/order_pay', {order_id: order_id}, function (data) {
                    var res = JSON.parse(data);
                    if (res.success) {
                        location.href = '/static/order/order_list.html'
                    }
                });
            }
        }
    });
    $.post('/order/get_order', {order_id: app_data.order_id}, function (data) {
        var res = JSON.parse(data);
        app_data.order_detail = res.result;
        app_data.order_detail.price_all = 0;
        $.each(res.result.commodity, function (index, item) {
            app_data.order_detail.price_all += parseInt(item.price) * parseInt(item.num)
        });
    });

});